home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
7684
/
7684.xpi
/
chrome
/
firefm.jar
/
content
/
fmVideoDialog.js
< prev
next >
Wrap
Text File
|
2009-07-04
|
3KB
|
76 lines
/**
* Copyright (c) 2008, Jose Enrique Bolanos, Jorge Villalobos
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Jose Enrique Bolanos, Jorge Villalobos nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
Components.utils.import("resource://firefm/fmCommon.js");
// Regular expression of a youtube URL enclosed by ""
const REGEX_YOUTUBE_URL = /"(http.+?youtube.+?)"/gi;
/**
* FireFM chrome namespace. We need a separate one because this one is defined
* per window.
*/
if (typeof(FireFMChrome) == 'undefined') {
var FireFMChrome = {};
};
/**
* Video dialog controller..
*/
FireFMChrome.VideoDialog = {
/* Logger for this object. */
_logger : null,
/**
* Initializes the object.
*/
init : function() {
this._logger = FireFM.getLogger("FireFMChrome.VideoDialog");
this._logger.debug("init");
let video = window.arguments[0].track.video;
// If video is from youtube, append "rel=0" to the URL to disable related
// videos.
let youtubeURLMatch = REGEX_YOUTUBE_URL.exec(video);
if (youtubeURLMatch) {
video = video.replace(
youtubeURLMatch[1], youtubeURLMatch[1] + encodeURIComponent("&rel=0"));
}
let div = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
div.innerHTML = video;
document.getElementById("fm-video-container").appendChild(div);
}
};
window.addEventListener(
"load", function() { FireFMChrome.VideoDialog.init(); }, false);